package com.minio.miniospringboot;

import io.minio.DownloadObjectArgs;
import io.minio.MinioClient;

/**
 * @ClassName: DownLoadFile
 * @Desc: TODO
 * @auther: <Bang>
 * @Date: 2023/03/17 14:41
 * @Version: 1.0
 * @Modified By:
 */
public class DownLoadFile {

    private static final String ENDPOINT = "http://192.168.96.156:9000";
    private static final String ACCESSKEY = "adminMinio";
    private static final String SECRETKEY = "adminMinio";
    private static final String BUCKET = "files";;
    public static final String OBJECT_NAME = "test.zip";
    public static final String FILENAME = "download.zip";

    public static void main(String[] args) {
        MinioClient minioClient = MinioClient.builder()
                .endpoint(ENDPOINT)
                .credentials(ACCESSKEY, SECRETKEY).build();
        try {
            minioClient.downloadObject(
                    DownloadObjectArgs.builder()
                            .bucket(BUCKET)
                            .object(OBJECT_NAME)
                            .filename(FILENAME)
                            .build());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
